package com.lin.bank.controller;

import com.lin.bank.config.reponse.Result;
import com.lin.bank.feign.RecordsFeign;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "账户管理")
@RestController
public class RecordsFeignController {

    @Resource
    private RecordsFeign recordsFeign;

    @ApiOperation(value = "查询自己的所有账单")
    @GetMapping("/getRecords")
    public Result selectPage(@RequestParam(name = "cardNo",required = true) String cardNo,
                      @RequestParam(name = "transactionDate1",required = true) String transactionDate1,
                      @RequestParam(name = "transactionDate2",required = true) String transactionDate2,
                      @RequestParam(name = "current",required = false,defaultValue = "1")Integer current,
                      @RequestParam(name = "size",required = false,defaultValue = "4")Integer size){
        return recordsFeign.selectPage(cardNo, transactionDate1, transactionDate2, current, size);
    }


    @GetMapping("/msg")
    public String msg(@RequestParam(name = "cardNo") String cardNo,
                      @RequestParam(name = "cardNo2")String cardNo2,
                      @RequestParam(name = "amount")Double amount,
                      @RequestParam(name = "balance1")Double balance1,
                      @RequestParam(name = "balance2")Double balance2){
        return recordsFeign.sendMsg(cardNo, cardNo2, amount, balance1, balance2);
    }


}
